var __extends =
    (this && this.__extends) ||
    (function () {
      var e = function (t, a) {
        return (e =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (e, t) {
              e.__proto__ = t;
            }) ||
          function (e, t) {
            for (var a in t)
              Object.prototype.hasOwnProperty.call(t, a) && (e[a] = t[a]);
          })(t, a);
      };
      return function (t, a) {
        function s() {
          this.constructor = t;
        }
        if ("function" != typeof a && null !== a)
          throw new TypeError(
            "Class extends value " + String(a) + " is not a constructor or null"
          );
        e(t, a),
          (t.prototype =
            null === a
              ? Object.create(a)
              : ((s.prototype = a.prototype), new s()));
      };
    })(),
  MessageViewController = (function (e) {
    function t() {
      var t = e.call(this) || this;
      return (
        (t.messageArr = []),
        (t.chatLimitInt = 0),
        (t.chatMsgTotalHeigh = 0),
        (t.chatFromServerMessageFn = {
          caller: t,
          code: 1033,
          method: function (e) {
            (t.messageArr = []),
              (t.messageArr = e.list),
              t.panel_message.removeChildren(),
              (t.chatMsgTotalHeigh = 0);
            for (var a = 0, s = t.messageArr.length; a < s; a++) {
              var r = e.list[a];
              if (
                "系统消息" == e.list[a].fname ||
                -1 != e.list[a].fname.indexOf("系统")
              ) {
                var n = new ChatLineView();
                (t.chatline = n),
                  n.systemChatLineMessage(t.messageArr[a]),
                  t.messageArr.push(n),
                  n.on(Laya.Event.CLICK, t, t.onDidChatLineClick, [r]),
                  t.panel_message.addChild(n),
                  (n.y = t.chatMsgTotalHeigh),
                  (t.chatMsgTotalHeigh += n.height);
              }
            }
            (t.panel_message.vScrollBar.max = t.panel_message.contentHeight),
              (t.panel_message.vScrollBar.value =
                t.panel_message.vScrollBar.min);
          },
        }),
        t.btn_message_back.on(Laya.Event.CLICK, t, t.messageBackPre),
        (t.panel_message.vScrollBarSkin = "comp/Server/chatPaneScroll.png"),
        (t.panel_message.vScrollBar.isVertical = !0),
        (t.panel_message.vScrollBar.elasticBackTime = 600),
        (t.panel_message.vScrollBar.elasticDistance = 200),
        WebSocketService.addListener(t.chatFromServerMessageFn, !0),
        WebSocketService.addListener({
          caller: t,
          code: 42081,
          method: t.onLoadGroupTeamDataFn,
        }),
        t
      );
    }
    return (
      __extends(t, e),
      (t.openView = function () {
        return (
          null == this.messageVC && (this.messageVC = new t()),
          (this.messageVC.messageArr = []),
          WebSocketService.send({ c: 1033, d: { roleid: 1e3 } }),
          this.messageVC
        );
      }),
      (t.prototype.onDidChatLineClick = function (e) {
        if ("" != e.target.name) {
          var t = "";
          -1 != e.content.indexOf("(") &&
            ((t = this.getParenthesesStr(e.content)),
            -1 != e.content.indexOf("申请加入您")
              ? WebSocketService.send({ c: 42091, d: { roleId: t } })
              : WebSocketService.send({ c: 42081, d: { roleId: t } }));
        }
      }),
      (t.prototype.getParenthesesStr = function (e) {
        var t = e.match(/\((.+?)\)/g)[0];
        return t.substring(1, t.length - 1);
      }),
      (t.prototype.onLoadGroupTeamDataFn = function (e) {
        ToastView.toastView(e.msg);
      }),
      (t.prototype.updateChatPanelView = function () {
        this.panel_message.removeChildren(), (this.chatMsgTotalHeigh = 0);
        for (var e, t = 0, a = this.messageArr.length; t < a; t++)
          ((e = this.messageArr[t]).y = this.chatMsgTotalHeigh),
            (this.chatMsgTotalHeigh += e.height),
            this.panel_message.addChild(e);
        (this.panel_message.vScrollBar.max = this.panel_message.contentHeight),
          (this.panel_message.vScrollBar.value =
            this.panel_message.vScrollBar.max);
      }),
      (t.prototype.messageBackPre = function () {
        this.removeSelf();
      }),
      t
    );
  })(ui.MessageController.MessageViewControllerUI);
